var urltest = sessionStorage.getItem("urltest");
$("#smart_search").click(function() {
	$("#rush_tips").html("");
	//	$("#ID_card_tips").html("");
	var num = $('#num_rush').val();
	//	var ID_card = $('#SFZ').html();
	var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
	if(num == "") {
		$("#rush_tips").html("充值金额不能为空")
	} else if(!(/(^[1-9]\d*$)/.test(num))) {
		$("#rush_tips").html("充值金额必须为整数");
		return false;
	} else {

		//		$("#SFZ").html(ID_card);
		var canshu = {
			"identityCard": $('#SFZ').html(),
			"meterId": $('#dianbiao').html(),
			"roomId": $('#sushe').html(),
			"rctualPayAmount": $('#num_rush').val(),
			"rate": $("#beilv").html(),
		}
		var canshu = JSON.stringify(canshu);
		sessionStorage.setItem("canshu", canshu);
		window.location.href = "Confirmation_payment.html";
	}
})
$(function() {
	var address = sessionStorage.getItem("address");
	var ID_card = sessionStorage.getItem("ID_card");
	var address = JSON.parse(address);
	$('#quyu').html(address.sel_1);
	$('#sushe').html(address.sel_3);
	$("#dianbiao").html(address.sel_4)
	$("#SFZ").html(ID_card);
	var obj = {
		"area": address.sel_1,
		"roomName": address.sel_3,
		"meterId": address.sel_4,
	};
	var req = JSON.stringify(obj);
	$.ajax({
		contentType: "application/json; charset=utf-8",
		type: "POST",
		url: urltest + "/notcheck/getHouseMeterInformationDetile",
		data: req,
		async: false,
		dataType: "json",
		beforeSend: function() {
			$("#showResult").show();
		},
		success: function(msg) {
			console.log(msg);
			if(msg.resCode == 200) {
				$("#showResult").hide();
				$("#shengyu").html(msg.obj.Balance);
				if(msg.obj.Balance > 0) {
					$("#zhuangtai").html("正常");
				} else {
					$("#zhuangtai").html("已停电");
				}
				$("#cishu").html(msg.obj.times);

				$("#beilv").html(msg.obj.Rate);
			} else if(msg.resCode == 404) {
				window.location.href = "jq404.html";
			} else {
				//				alert(msg.resmsg + "，请稍后重试");
				$("#tips").html(msg.resmsg + "，请稍后重试");
				$('#myModal').modal('show');
			}

		},
		error: function() {
			//			alert(msg.resmsg);
			$("#tips").html(msg.resmsg);
			$('#myModal').modal('show');

			$("#showResult").hide();
		}
	});
})

$('#goto_jilu').click(function() {
	window.location.href='Recharge_record.html';
});